<div class="pt15 pl15">当前位置：<span class="layui-breadcrumb"><a href="/">首页</a><a href="/adminuser/user/index">用户管理</a><a><cite>添加用户</cite></a></span></div>
<div class="layui-fluid">
    <div class="layui-card p30">		
		<div class="border-b pb15 f22">添加用户</div>
		<form class="layui-form" action="/adminuser/user/update" id="userupdate-form">
		<input type="hidden" name="id" id="userid" value="<?= $model->id?>"/>
		<div class="layui-card-body pt30 pb15">		
			<div class="layui-container">
				<div class="layui-row">
					<div class="layui-col-xs12 layui-col-md6">	
						<div class="layui-form-item">
						  <label class="layui-form-label">用户名：</label>
						  <div class="layui-input-block">
						    <input type="text" name="username" id="username" value="<?= $model->username?>" placeholder="请输入用户名"  class="layui-input">
						  </div>
						</div>
						<div class="layui-form-item">
						  <label class="layui-form-label">手机号：</label>
						  <div class="layui-input-block">
							<input type="text" name="mobile" value="<?= $model->mobile?>"  placeholder="请输入手机号"  class="layui-input">
						  </div>
						</div>
					</div>				
				</div>       
			</div>
		</div>		
		<div class="pt30 border-t text-c"> 
			<button class="layui-btn layui-btn-normal" type="submit"  id="userupdate-submit">提交</button>
			<a class="layui-btn layui-btn-primary" href="/adminuser/user/index">取消</a>					
		</div>		
		</form>		
    </div>
</div>
<script>
    function checkexits(){
        var userid = $("#userid").val();
        var username = $("#username").val();
        $params = JSON.stringify({'userid':userid,'username':username});
        $exam_back = ajaxSynchroPostRequest("/adminuser/user/check-exist",$params);
        console.log($exam_back);
        if($exam_back.success == 1 && $exam_back.exist==1){
            layer.msg("用户名已存在");
            return false;
        }
        else{
            return true;
        }
    }
    $("#username").blur(function(event){
        checkexits();
    });
    $("#userupdate-submit").on('click',function(){
        if(checkexits()){
            $("#userupdate-form").submit();
        }
    });
    
</script>